/*
 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 SPDX-License-Identifier: Apache-2.0
*/

@use '../tokens' as awsui;
@use './constants' as constants;

// To reduce bluriness of heavy font weight on MacOS
@mixin font-smoothing {
  -webkit-font-smoothing: awsui.$font-smoothing-webkit;
  -moz-osx-font-smoothing: awsui.$font-smoothing-moz-osx;
}

@mixin default-text-style {
  @include font-body-m;
  color: awsui.$color-text-body-default;
  font-weight: constants.$font-weight-normal;
  font-family: constants.$font-family-base;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
}

@mixin font-body-s {
  font-size: awsui.$font-size-body-s;
  line-height: awsui.$line-height-body-s;
  letter-spacing: awsui.$letter-spacing-body-s;
}

@mixin font-body-m {
  font-size: awsui.$font-size-body-m;
  line-height: awsui.$line-height-body-m;
}

@mixin font-heading-xs($weight: true) {
  font-size: awsui.$font-size-heading-xs;
  line-height: awsui.$line-height-heading-xs;
  @if $weight {
    font-weight: awsui.$font-weight-heading-xs;
    @include font-smoothing;
  }
}

@mixin font-heading-s($weight: true) {
  font-size: awsui.$font-size-heading-s;
  line-height: awsui.$line-height-heading-s;
  letter-spacing: awsui.$letter-spacing-heading-s;
  @if $weight {
    font-weight: awsui.$font-weight-heading-s;
    @include font-smoothing;
  }
}

@mixin font-heading-m($weight: true) {
  font-size: awsui.$font-size-heading-m;
  line-height: awsui.$line-height-heading-m;
  letter-spacing: awsui.$letter-spacing-heading-m;
  @if $weight {
    font-weight: awsui.$font-weight-heading-m;
    @include font-smoothing;
  }
}

@mixin font-heading-l($weight: true) {
  font-size: awsui.$font-size-heading-l;
  line-height: awsui.$line-height-heading-l;
  letter-spacing: awsui.$letter-spacing-heading-l;
  @if $weight {
    font-weight: awsui.$font-weight-heading-l;
    @include font-smoothing;
  }
}

@mixin font-heading-xl($weight: true) {
  font-size: awsui.$font-size-heading-xl;
  line-height: awsui.$line-height-heading-xl;
  letter-spacing: awsui.$letter-spacing-heading-xl;
  @if $weight {
    font-weight: awsui.$font-weight-heading-xl;
    @include font-smoothing;
  }
}

@mixin font-display-l {
  font-size: awsui.$font-size-display-l;
  line-height: awsui.$line-height-display-l;
  letter-spacing: awsui.$letter-spacing-display-l;
}

@mixin font-inherit {
  font-size: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

@mixin font-button {
  font-weight: awsui.$font-weight-button;
  @include font-smoothing;
}

@mixin font-label {
  @include font-body-m();
  font-weight: awsui.$font-display-label-weight;
}

@mixin font-panel-header {
  font-size: awsui.$font-panel-header-size;
  letter-spacing: awsui.$letter-spacing-heading-m;
  line-height: awsui.$font-panel-header-line-height;
  font-weight: awsui.$font-weight-heading-l;
  @include font-smoothing;
}

@mixin font-code-inline {
  font-size: awsui.$font-size-body-s;
  line-height: awsui.$line-height-body-m;
}

@mixin font-code-block {
  font-size: awsui.$font-size-body-m;
  line-height: awsui.$line-height-body-m;
}

@mixin font($font-size) {
  @if $font-size == body-s {
    @include font-body-s;
  }
  @if $font-size == body-m {
    @include font-body-m;
  }
  @if $font-size == heading-xs {
    @include font-heading-xs($weight: false);
  }
  @if $font-size == heading-s {
    @include font-heading-s($weight: false);
  }
  @if $font-size == heading-m {
    @include font-heading-m($weight: false);
  }
  @if $font-size == heading-l {
    @include font-heading-l($weight: false);
  }
  @if $font-size == heading-xl {
    @include font-heading-xl($weight: false);
  }
  @if $font-size == display-l {
    @include font-display-l;
  }
  @if $font-size == inherit {
    @include font-inherit;
  }
}
